package com.boot.cluster.worker.bean;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Pair<T, E> {

	public T t;
	public E e;

	public Pair() {

	}

	public Pair(T t, E e) {
		this.t = t;
		this.e = e;
	}

	public static <T1, T2> Pair<T1, T2> of(T1 t, T2 e) {
		return new Pair<>(t, e);
	}

	public static <T, E> List<Pair<T, E>> wrapList(Pair<T, E>[]  pairs) {
		if (pairs == null) {
			return null;
		}
		List<Pair<T, E>> result = new ArrayList<>(pairs.length);
		result.addAll(Arrays.asList(pairs));
		return result;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
